<?php

$params = array_merge(
        require __DIR__ . '/../../common/config/params.php',
        require __DIR__ . '/params.php',
);

return [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'api\controllers',
    'defaultRoute' => 'index/default',
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-api',
            'enableCookieValidation' => true,
            'enableCsrfValidation' => false,
            'cookieValidationKey' => '283923293jdwiehfisf2934r92348ur923fwkefjiwe',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ],
        ],
        'user' => [
            'class' => 'api\components\User',
        ],
        'session' => [
            'name' => 'advanced-api',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'logFile' => '@api/runtime/logs/error/error.' . date('Ymd') . '.log',
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'index/error',
            'class' => 'api\extensions\ApiHttpException'
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
                'api/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
            ],
        ],
    ],
    'modules' => [
        'coupon' => [
            'class' => 'api\modules\coupon\Coupon',
        ],
        'goods' => [
            'class' => 'api\modules\goods\Goods',
        ],
        'home' => [
            'class' => 'api\modules\home\Home',
        ],
        'user' => [
            'class' => 'api\modules\user\User',
        ],
        'mall' => [
            'class' => 'api\modules\mall\Mall',
        ],
        'active' => [
            'class' => 'api\modules\active\Active',
        ],
        'order' => [
            'class' => 'api\modules\order\Order',
        ]
    ],
    'params' => $params,
];
